﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GameBase;
using GameBase.Form;
using GameBase.Form.Control;
using Microsoft.Xna.Framework.Input;



namespace GalaxyPresident
{

    public abstract class GameScreen : VisibleGroup
    {
        protected Game1 game;
        public static Color PANEL_COLOR = Color.DarkSlateGray;
        public static Color CONTROL_COLOR = Color.CornflowerBlue;
        public static Color FORCOLOR = /*Color.CornflowerBlue*/new Color(140,190,255);

        private MouseState lastMouseState;
        private MouseState mouseState;

        public MouseState LastMouseState
        {
            get { return lastMouseState; }
        }


        public MouseState MouseState
        {
            get { return mouseState; }
        }

        public Game1 Game
        {
            get { return game; }
            set { game = value; }
        }
        public Random Random
        {
            get { return Constant.random; }
        }
        protected MyForm form;

        public MyForm Form
        {
            get { return form; }
            set { form = value; }
        }
        public virtual void OnCloseGame()
        {

        }

        public GameScreen(Game1 game)
        {
            this.game = game;
            form = new MyForm(1024, 768,
                game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height);
            base.AddChild(form);
            
        }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            
            #region Zoom and Scroll processing
            mouseState = Mouse.GetState();
            /*scrollScreen();
            zoomScreen();*/
            //
            if (LastMouseState.LeftButton != MouseState.LeftButton)
            {
                if (MouseState.LeftButton == ButtonState.Pressed)
                {
                    MousePressed(form.MouseInput(mouseState));
                }
                else
                {
                    MouseReleased(form.MouseInput(mouseState));
                }
            }
            MouseHandle();
            HandleKeyBoard();
            lastMouseState = MouseState;
            #endregion
        }
        protected virtual void HandleKeyBoard()
        {
        }
        protected virtual void MouseHandle()
        {
        }
        protected virtual void MousePressed(bool onForm)
        {
        }
        protected virtual void MouseReleased(bool onForm)
        {

        }
        public void AddControl(MyControl control)
        {
            Form.Add(control);
        }
    }
}
